/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormEquipos.java
 *
 * Created on 27/11/2011, 01:39:15 PM
 */

package Vista;
import Modelo.Equipos;
/**
 *
 * @author Luis
 */
public class FormEquipos extends javax.swing.JFrame {

    /** Creates new form FormEquipos */
    public FormEquipos() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtjuegosperdidos = new java.awt.TextField();
        txtjuegosganados = new java.awt.TextField();
        txtciudad = new java.awt.TextField();
        txtjuegosjugados = new java.awt.TextField();
        choiceañofundacion = new java.awt.Choice();
        lblnombreestadio = new java.awt.Label();
        lbljuegosjugados = new java.awt.Label();
        lblañofundacion = new java.awt.Label();
        lblciudad = new java.awt.Label();
        txtcodigoequipo = new java.awt.TextField();
        lbljuegosganados = new java.awt.Label();
        lbljuegosperdidos = new java.awt.Label();
        txtnombreestadio = new java.awt.TextField();
        lblcodigoequipo = new java.awt.Label();
        txtnombreequipo = new java.awt.TextField();
        lblnombreequipo = new java.awt.Label();
        jButtongrabar = new javax.swing.JButton();
        jButtoneliminar = new javax.swing.JButton();
        jButtoncancelar = new javax.swing.JButton();
        jButtonconsultar = new javax.swing.JButton();
        jButton1consultajugadores = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Equipos"));

        txtjuegosperdidos.setEnabled(false);

        txtjuegosganados.setEnabled(false);

        txtjuegosjugados.setEnabled(false);

        choiceañofundacion.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                choiceañofundacionItemStateChanged(evt);
            }
        });

        lblnombreestadio.setBackground(new java.awt.Color(240, 240, 240));
        lblnombreestadio.setFont(new java.awt.Font("Arial", 1, 12));
        lblnombreestadio.setText("Nombre del Estadio:");

        lbljuegosjugados.setBackground(new java.awt.Color(240, 240, 240));
        lbljuegosjugados.setFont(new java.awt.Font("Arial", 1, 12));
        lbljuegosjugados.setText("Juegos Jugados:");

        lblañofundacion.setBackground(new java.awt.Color(240, 240, 240));
        lblañofundacion.setFont(new java.awt.Font("Arial", 1, 12));
        lblañofundacion.setText("Año de Fundación: ");

        lblciudad.setBackground(new java.awt.Color(240, 240, 240));
        lblciudad.setFont(new java.awt.Font("Arial", 1, 12));
        lblciudad.setText("Ciudad: ");

        txtcodigoequipo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtcodigoequipoKeyTyped(evt);
            }
        });

        lbljuegosganados.setBackground(new java.awt.Color(240, 240, 240));
        lbljuegosganados.setFont(new java.awt.Font("Arial", 1, 12));
        lbljuegosganados.setText("Juegos Ganados:");

        lbljuegosperdidos.setBackground(new java.awt.Color(240, 240, 240));
        lbljuegosperdidos.setFont(new java.awt.Font("Arial", 1, 12));
        lbljuegosperdidos.setText("Juegos Perdidos: ");

        lblcodigoequipo.setBackground(new java.awt.Color(240, 240, 240));
        lblcodigoequipo.setFont(new java.awt.Font("Arial", 1, 12));
        lblcodigoequipo.setText("Codigo del Equipo:");

        lblnombreequipo.setBackground(new java.awt.Color(240, 240, 240));
        lblnombreequipo.setFont(new java.awt.Font("Arial", 1, 12));
        lblnombreequipo.setText("Nombre del Equipo: ");

        jButtongrabar.setText("Grabar");
        jButtongrabar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtongrabarMouseClicked(evt);
            }
        });

        jButtoneliminar.setText("Eliminar");

        jButtoncancelar.setText("Cancelar");
        jButtoncancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtoncancelarActionPerformed(evt);
            }
        });

        jButtonconsultar.setText("Consultar");

        jButton1consultajugadores.setText("Consultar Jugadores");
        jButton1consultajugadores.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1consultajugadoresMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblnombreequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblañofundacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblcodigoequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtcodigoequipo, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtnombreequipo, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(txtciudad, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(choiceañofundacion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE))
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbljuegosperdidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbljuegosganados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblnombreestadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbljuegosjugados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtjuegosganados, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                    .addComponent(txtnombreestadio, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtjuegosjugados, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                    .addComponent(txtjuegosperdidos, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                .addGap(180, 180, 180))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButtongrabar, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtoneliminar, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtoncancelar, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonconsultar))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1consultajugadores)
                        .addGap(159, 159, 159)))
                .addGap(201, 201, 201))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtcodigoequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblnombreestadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtnombreestadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblcodigoequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(56, 56, 56)
                                .addComponent(lblciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(lbljuegosjugados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(38, 38, 38)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbljuegosperdidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(txtjuegosperdidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtnombreequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(choiceañofundacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(lblnombreequipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblañofundacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtjuegosjugados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(txtjuegosganados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbljuegosganados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtongrabar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtoneliminar)
                    .addComponent(jButtoncancelar)
                    .addComponent(jButtonconsultar))
                .addGap(18, 18, 18)
                .addComponent(jButton1consultajugadores)
                .addGap(58, 58, 58))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-616)/2, (screenSize.height-438)/2, 616, 438);
    }// </editor-fold>//GEN-END:initComponents

private void jButtongrabarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtongrabarMouseClicked
String datos;

 datos = txtcodigoequipo.getText();
 if(datos.length()==0)
 {
     Mensajes.Aviso("Codigo vacio", "Equipos");
     txtcodigoequipo.requestFocusInWindow();
     return;
 }
   datos = txtnombreequipo.getText();
   if (datos.length()==0)
   {
      Mensajes.Aviso("Nombre vacio", "Equipos");
       txtnombreequipo.requestFocusInWindow();
       return;
   }
  datos = choiceañofundacion.getSelectedItem();
  if(datos.length()==0)
  {
      Mensajes.Aviso("Seleccione el Año", "Equipos");
       choiceañofundacion.requestFocusInWindow();
       return;

  }
    datos = txtciudad.getText();
     if(datos.length()==0)
     {
         Mensajes.Aviso("Ciudad Vacia", "Equipos");
         txtciudad.requestFocusInWindow();
         return;
     }
  datos = txtnombreestadio.getText();
  if(datos.length()==0)
  {
      Mensajes.Aviso("Nombre De Estadio Vacio", "Equipos");
      txtnombreestadio.requestFocusInWindow();
      return;
  }
    datos = txtjuegosjugados.getText();
    if(datos.length()==0)
    {
        Mensajes.Aviso("Ingrese Los Juegos Jugados", "Equipos");
        txtjuegosjugados.requestFocusInWindow();
        return;
    }
  datos = txtjuegosganados.getText();
  if(datos.length()==0)
  {
      Mensajes.Aviso("Ingrese Los juegos Ganados" , "Equipos");
      txtjuegosganados.requestFocusInWindow();
      return;
 }
   datos  = txtjuegosperdidos.getText();
 if(datos.length()==0)
 {
     Mensajes.Aviso("Ingrese Los Juegos Perdidos" , "Equipos");
     txtjuegosperdidos.requestFocusInWindow();
     return;
 }
  /*  
   Equipos.addEquipo(txtcodigoequipo.getText(),
                      txtnombreequipo.getText(),
                       choiceañofundacion.getSelectedItem(),
                       txtciudad.getText(),
                       txtnombreestadio.getText(),0,0,0);
                        
                        

  txtcodigoequipo.setText("");
  txtnombreequipo.setText("");
  txtciudad.setText("");
  txtnombreestadio.setText(datos);
  txtjuegosjugados.setText("");
  txtjuegosganados.setText("");
  txtjuegosperdidos.setText("");
  txtcodigoequipo.requestFocusInWindow();*/
}//GEN-LAST:event_jButtongrabarMouseClicked

private void txtcodigoequipoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcodigoequipoKeyTyped
 String datos;
    
    datos = txtcodigoequipo.getText();
    
    char caracter = evt.getKeyChar();
    if(caracter < '0' || caracter > '9' )
        evt.consume();
    else
        if(datos.length()==2)
            evt.consume();
}//GEN-LAST:event_txtcodigoequipoKeyTyped

private void jButtoncancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoncancelarActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButtoncancelarActionPerformed

private void choiceañofundacionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_choiceañofundacionItemStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_choiceañofundacionItemStateChanged

private void jButton1consultajugadoresMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1consultajugadoresMouseClicked
// TODO adg code here:
    new Jugadores().setVisible(true);
}//GEN-LAST:event_jButton1consultajugadoresMouseClicked


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FormEquipos().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private java.awt.Choice choiceañofundacion;
    private javax.swing.JButton jButton1consultajugadores;
    private javax.swing.JButton jButtoncancelar;
    private javax.swing.JButton jButtonconsultar;
    private javax.swing.JButton jButtoneliminar;
    private javax.swing.JButton jButtongrabar;
    private javax.swing.JPanel jPanel1;
    private java.awt.Label lblañofundacion;
    private java.awt.Label lblciudad;
    private java.awt.Label lblcodigoequipo;
    private java.awt.Label lbljuegosganados;
    private java.awt.Label lbljuegosjugados;
    private java.awt.Label lbljuegosperdidos;
    private java.awt.Label lblnombreequipo;
    private java.awt.Label lblnombreestadio;
    private java.awt.TextField txtciudad;
    private java.awt.TextField txtcodigoequipo;
    private java.awt.TextField txtjuegosganados;
    private java.awt.TextField txtjuegosjugados;
    private java.awt.TextField txtjuegosperdidos;
    private java.awt.TextField txtnombreequipo;
    private java.awt.TextField txtnombreestadio;
    // End of variables declaration//GEN-END:variables

}
